/* GUI CONVERTED from rprsiq2a.p (converter v1.75) Mon Oct 23 21:04:57 2000 */
/* rprsiq2a.p - RESOURCE LOAD DETAIL INQUIRY                            */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*F0PN*/ /*K17J*/
/*V8:ConvertMode=Report                                        */
/* REVISION: 7.3     LAST MODIFIED: 09/06/94    BY: jxz  *FP82*         */
/* REVISION: 7.3     LAST MODIFIED: 10/17/95    BY: qzl *G0ZB*          */
/* REVISION: 8.6     LAST MODIFIED: 11/04/97    BY: bvm *K17J*          */
/* REVISION: 8.6     LAST MODIFIED: 02/13/97    BY: *H0QB*  Russ Witt   */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane    */
/* REVISION: 8.6E     LAST MODIFIED: 09/17/98   BY: *J2Z1* G.Latha      */
/* REVISION: 9.1      LAST MODIFIED: 08/08/00   BY: *N0J4* Mudit Mehta  */
/* REVISION: 9.1      LAST MODIFIED: 10/23/00   BY: *N0T0* Katie Hilbert    */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

/*FP82*/ {mfdeclre.i}
/*N0J4*/ {gplabel.i} /* EXTERNAL LABEL INCLUDE */

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rprsiq2a_p_4 "Per Col"
/* MaxLen: Comment: */

/*N0J4*------------START COMMENT----------------
 * &SCOPED-DEFINE rprsiq2a_p_1 "Workdays      "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsiq2a_p_2 "Total Load    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsiq2a_p_3 " LOAD % OF CAPACITY "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsiq2a_p_5 "Capacity      "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsiq2a_p_6 " W/O:"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsiq2a_p_7 "Over/Under    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsiq2a_p_8 "Cumulative    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsiq2a_p_9 "Past    "
 * /* MaxLen: Comment: */
 *
 * /*J2Z1** &SCOPED-DEFINE rprsiq2a_p_10 "Press space bar to display graph" */
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsiq2a_p_11 "Item:"
 * /* MaxLen: Comment: */
 *N0J4*----------END COMMENT----------------- */

/* ********** End Translatable Strings Definitions ********* */

/*K17J*/ {wbrp02.i}


/*FP82*/ define shared variable site like si_site.
/*FP82*/ define shared variable start like rq_start.
/*FP82*/ define shared variable rscde like rq_rsc.
     define variable interval as integer extent 8 no-undo.
     define variable sdate like rq_start extent 8 no-undo.
/*H0QB*  define variable load as decimal extent 8 format "->>>,>>9". */
/*H0QB*/ define new shared variable load as decimal extent 8 format "->>>,>>9"
                                                                no-undo.
/*H0QB*  define variable cap as decimal extent 8 format "->>>,>>9".   */
/*H0QB*/ define new shared variable cap as decimal extent 8 format "->>>,>>9"
/*H0QB*/                                 no-undo.
     define variable ovund as decimal extent 8 format "->>>,>>9" no-undo.
     define variable cum as decimal extent 8 format "->>>,>>9" no-undo.
     define variable workdays as integer extent 8 format ">>>>,>>9" no-undo.
     define variable det_load as decimal extent 8 format "->>>,>>9" no-undo.
     define variable i as integer no-undo.
     define variable j as integer no-undo.
     define variable qty like rq_qty no-undo.
     define variable nonwdays as decimal no-undo.
     define variable elapsedays as integer no-undo.
     define variable wdays as integer no-undo.
     define variable overlap as integer no-undo.
     define variable wointerval as integer no-undo.
     define variable ltoffperiod as integer no-undo.
     define variable lead as integer no-undo.
     define variable num_intervals as integer initial 7 no-undo.
/*H0QB*FP82* define shared variable dwm as character format "!" label "D/W/M". */
/*N0T0* /*H0QB*/ define shared variable dwm as character format "!" label "D/W/M/P". */
/*N0T0*/ define shared variable dwm as character.
/*FP82*/ define shared variable idays as integer
/*H0QB*                               format ">>>>>9" label "Per Column". */
/*H0QB*/                              format ">>>>>9" label {&rprsiq2a_p_4}.
     define variable monthend as integer no-undo.

     define new shared variable vq_-ratio as integer extent 7 no-undo.
     define new shared variable vq_-title as character no-undo.
     define new shared variable vq_-period as date extent 14 no-undo.
     define new shared variable vq_-bar-color as character no-undo.
/*H0QB*/ define new shared variable vq_-day-week-month as character no-undo.
     define variable x as integer no-undo.

/*FP82*/ define variable dev like prd_dev no-undo.
/*FP82*/ define shared variable dev1 like prd_dev.
/*FP82*/ define variable path like prd_path no-undo.
/*FP82*/ define shared variable path1 like prd_path.
/*N0T0***********BEGIN DELETE OF UNUSED LOCAL VARIABLES
 * define variable start1 like rq_start.
 * define variable rscde1 like rq_rsc.
 * define variable holiday as integer.
 * define variable wostart as integer.
 * define variable offset like rq_lt_off.
 * define variable ltoff like rq_lt_off.
 * define variable pge like mfc_logical initial "n".
 *N0T0***********END DELETE*/

/*FP82*/ hide frame b.
/*FP82*/ hide frame d.
/*FP82*/ dev = dev1.
/*FP82*/ path = path1.

        /* COMPUTE START DATES */
        sdate[1] = today.
        {mfcsdate.i}

        do i = 1 to num_intervals + 1:
           sdate[i] = max(sdate[i],today).
           if i > 1 then interval[i - 1] = max(sdate[i] - sdate[i - 1],0).
        end.

        /* INITIALIZE VARIABLES */
        assign
           cap = 0
           workdays = 0
           load = 0
           ovund = 0
           cum = 0.

        /* CALCULATE WORKING DAYS IN EACH INTERVAL */
        {mfcwdays.i site}
        do i = 1 to num_intervals + 1:
           workdays[i] = max(workdays[i],0).
        end.

        /* CALCULATE CAPACITY IN EACH INTERVAL */
        {mfccap.i site}

        {mfcsdate.i}
        {mfcwdays.i site}
        workdays[1] = max(workdays[1],0).
        sdate[1] = low_date.

        display
/*N0J4*    space(15) {&rprsiq2a_p_9} sdate[2 for 6] skip */
/*N0J4*/   getTermLabelRt("PAST",20) + "    "  format "x(24)" sdate[2 for 6]
/*N0J4*/   skip
           space(15) sdate[2] - 1 sdate[3] - 1 sdate[4] - 1 sdate[5] - 1
           sdate[6] - 1 sdate[7] - 1 sdate[8] - 1 skip
           space(15)
           "-------- -------- -------- -------- -------- -------- --------"
/*N0J4*
 *         {&rprsiq2a_p_1} workdays[1 for 7] skip
 *         {&rprsiq2a_p_5} cap[1 for 7]
 *N0J4*/
/*N0J4*/   getTermLabel("WORKDAYS",14) format "x(14)" workdays[1 for 7] skip
/*N0J4*/   getTermLabel("CAPACITY",14) format "x(14)" cap[1 for 7]
        with frame b width 80 no-labels STREAM-IO /*GUI*/ .

        /* CALCULATE  LOAD IN EACH PERIOD  */
/*K17J*/   if c-application-mode <> 'web':u then
              pause 0 no-message.
        if dev = "terminal" then do:
           {mfmsg.i 401 1}
           /* "CALCULATING LOAD" */
        end.

        find shop_cal no-lock where shop_site = site
        and shop_wkctr = "" and shop_mch = "" no-error.
        if not available shop_cal then
           find shop_cal no-lock where shop_site = ""
           and shop_wkctr = "" and shop_mch = "" no-error.
        if available shop_cal then do:

           for each rq_mstr where rq_rsc = rscde
           and rq_site = site
           no-lock by rq_part:
                
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


          for each wo_mstr where wo_part = rq_part
          and (wo_due >= rq_start or rq_start = ?)
          and (wo_due <= rq_end or rq_end = ?)
          and (wo_qty_ord - wo_qty_comp - wo_qty_rjct > 0)
          and wo_status <> "C"
/*G0ZB*/          and wo_type <> "C"
          and wo_site = rq_site
          no-lock by wo_nbr:
                
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


             /* CALCULATE LOAD INTERVALS FOR A GIVEN WORK ORDER  */
             {mfcload.i}

             /* DISPLAY WORK ORDERS DETAIL */
             display
/*N0J4*      {&rprsiq2a_p_6} wo_nbr {&rprsiq2a_p_11} wo_part skip */
/*N0J4*/     " " + getTermLabelRtColon("WORK_ORDER",4) format "x(5)" wo_nbr
/*N0J4*/     getTermLabelRtColon("ITEM",5) format "x(5)" wo_part skip
             space(15) det_load[1 for 7] skip
             with no-labels width 80 STREAM-IO /*GUI*/ .

          end.
           end.
        end.

        /* DISPLAY LOAD OVER/UNDER AND CUMULATIVE */
/*N0J4*  display {&rprsiq2a_p_2} load[1 for 7] */
/*N0J4*/ display getTermLabel("TOTAL_LOAD",14) format "x(14)" load[1 for 7]
        with frame d no-labels width 80 STREAM-IO /*GUI*/ .

        do i = 1 to num_intervals + 1:
           assign
              ovund[i] = cap[i] - load[i]
              ovund[i] = integer(ovund[i])
              cum[i] = ovund[i].
           if i > 1 then cum[i] = cum[i] + cum[i - 1].
        end.

/*N0J4*
 *       display {&rprsiq2a_p_7} ovund[1 for 7] with frame d no-labels.
 *       display {&rprsiq2a_p_8} cum[1 for 7] with frame d no-labels.
 *N0J4*/
/*N0J4*/ display getTermLabel("OVER/UNDER",14)
/*N0J4*/             format "x(14)" ovund[1 for 7] with frame d no-labels STREAM-IO /*GUI*/ .
/*N0J4*/ display getTermLabel("CUMULATIVE",14)
/*N0J4*/             format "x(14)" cum[1 for 7] with frame d no-labels STREAM-IO /*GUI*/ .
/*K17J*/   if c-application-mode <> 'web':u then
              pause 0 no-message.

        if path = "terminal"
/*K17J*/      and c-application-mode <> 'web':u then

           repeat:

/*J2Z1*/   /* HARDCODED MESSAGE HAS BEEN REPLACED      */
/*J2Z1**   message {&rprsiq2a_p_10}. */
/*J2Z1*/   {mfmsg.i 1143 1}
           readkey.

           if lastkey = 32 then do:

/*H0QB*/  vq_-day-week-month = dwm.
          do x = 1 to 7:
             assign
                vq_-period[x] = sdate[x]
                vq_-period[x + 7] = sdate[x + 1] - 1
/*H0QB*      vq_-ratio[x] = load[x] / cap[x] * 100.    */
/*H0QB*/        vq_-ratio[x] = truncate(load[x],0) / truncate(cap[x],0) * 100.
          end.

          /* ASSIGN THE COLORS */
          assign vq_-bar-color = if opsys eq "msdos"
                     and terminal eq "co80"
                     then "white/red"
                     else "message".

          /* ASSIGN THE TITLE */
/*N0J4*   assign vq_-title = {&rprsiq2a_p_3}. */
/*N0J4*/  assign vq_-title = " " +
/*N0J4*/         caps(getTermLabel("LOAD_PERCENT_OF_CAPACITY",30)) + " ".
          /* NOTE LEADING/TRAILING BLANKS */

/*H0QB*/ /*V8+*/
/*H0QB*/      
                  {gprun.i ""gpgraphw.p""}      
           end.
           else leave.
        end.
/*K17J*/ {wbrp04.i}
